package com.ruoyi.common.utils.httpclient.httpclient;

import java.io.Serializable;

import lombok.Builder;
import lombok.Data;

/**
 *
 */
@Data
@Builder
public class Result<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private String responseCode;

    private String responseMessage;

    private T responseData;

    @SuppressWarnings("rawtypes")
    private static final Result EMPTY_SUCCESS_RESULT = Result.success(null);

    @SuppressWarnings("unchecked")
    public static <T> Result<T> success() {
        return EMPTY_SUCCESS_RESULT;
    }

    public static <T> Result<T> success(T obj) {
        ResultBuilder<T> resultBuilder = new ResultBuilder<T>();
        return resultBuilder.responseData(obj)
                .responseCode("200")
                .responseMessage("success")
                .build();
    }




//    @SuppressWarnings("rawtypes")
//    public static Result failure(String code, String message) {
//        return Result.builder()
//                .responseCode(code)
//                .responseMessage(message).build();
//    }

    @SuppressWarnings("rawtypes")
    public static Result failure(String code, String message) {
        return Result.builder()
                .responseCode(code)
                .responseMessage(message).build();
    }

}

